//---------------------------------------------------------------------
//  This file is part of the Background Motion solution.
// 
//  Copyright (C) Mindscape (TM).  All rights reserved.
//  http://www.mindscape.co.nz
// 
//  THIS CODE AND INFORMATION ARE PROVIDED AS IS WITHOUT WARRANTY OF ANY
//  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
//  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
//  PARTICULAR PURPOSE.
//---------------------------------------------------------------------

using Mindscape.BackgroundMotion.Website.Controllers;
using Mindscape.BackgroundMotion.Website.Infrastructure;

namespace Mindscape.BackgroundMotion.Website.Views
{
  public sealed class LoginPresenter : PresenterBase<ILoginView, IMembershipController>
  {
    /// <summary>
    /// Authenticates a user based on a specified email address and password combination
    /// </summary>
    /// <param name="emailAddress">The email address.</param>
    /// <param name="password">The password.</param>
    /// <param name="rememberMe">if set to <c>true</c> [remember me].</param>
    public void Authenticate(string emailAddress, string password, bool rememberMe)
    {
      if (string.IsNullOrEmpty(emailAddress) || string.IsNullOrEmpty(password))
      {
        View.ShowValidationError();
      }
      else
      {
        Controller.Authenticate(emailAddress, password, rememberMe);
      }
    }
  }
}